<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title  am-cf" style="font-size: 20px;">任务列表</div>
                    <div class="am-u-lg-3 tpl-index-settings-button" style="float: right;width: 100%;">
                        <a href="{:url('Advertise/buy')}">
                            <button type="button" class="page-header-button">购买浏览数</button>
                        </a>
                        <span class="" style="float: right; font-size: 18px;margin:12px 5% 0 0;">当前剩余浏览数:<b style="color: red;padding-left:50px;">{$user.adnum}个</b></span>
                    </div>
                </div>

                <div class="widget-body  am-fr">
                    <div class="am-u-sm-12">
                      <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black ">
                            <thead>
                                <tr>
                                    <th>广告标题</th>
                                    <th>广告类型</th>
                                    <th>总发布浏览数</th>
                                    <th>剩余浏览数</th>
                                    
                                    <th>时间</th>
                                    <th>操作</th>
                                    
                                </tr>
                            </thead>
                            <tbody>
                                {foreach $rows as $vo}
                                <tr class="gradeX">
                                    <td class="am-text-middle">{$vo.title}</td> 
                                    <td class="am-text-middle">{$vo.type}</td>
                                    <td class="am-text-middle">{$vo.totalnum}</td>
                                    <td class="am-text-middle">{$vo.surplusnum}</td>
                                    <td class="am-text-middle">
                                        {$vo.createtime|date="Y-m-d H:i:s",###}
                                    </td>
                                    <td class="am-text-middle">
                                      <button onclick="recharge({$vo.id})" class="layui-btn">充值</button>
                                    </td>
                                </tr>
                                
                                {/foreach}
                            </tbody>
                        </table>
                      {$rows->render()}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    function recharge(id) {
       layer.prompt({
                    value: '',
                    title: '请输入充值数量',
                    // area: ['800px', '350px'] //自定义文本域宽高
                }, function(value, index, elem) {
                    var index = layer.load();
                    $.post('advertise/recharge',{id:id,num:value},function(rsp){
                        layer.closeAll();
                        layer.msg(rsp.msg, {
                          offset: 'auto',
                          anim: 6,
                          end:function(){
                           
                          }
                        });
                        if (rsp.code==0) {}else{
                           window.location.reload();
                         }  
                    })
                })
    }
</script>